package com.demarc.pesquisas.web.util;

import java.io.Serializable;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public class OptionSelectOne implements Serializable {

    private static final long serialVersionUID = -6219623202566298564L;
    private String label;
    private String value;

    public OptionSelectOne() {
        // Constructor default
    }

    public OptionSelectOne(String label, String value) {
        this.label = label;
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.value;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(label).append(value).toHashCode();
    }

    @Override
    public boolean equals(Object obj) {
        boolean isEquals = false;

        if (obj == this) {
            isEquals = true;
        } else if (obj instanceof OptionSelectOne) {
            OptionSelectOne optionSelectOne = (OptionSelectOne) obj;

            isEquals =
                    new EqualsBuilder().append(label, optionSelectOne.getLabel())
                            .append(value, optionSelectOne.getValue()).isEquals();
        }
        return isEquals;
    }
}
